local module = {}

function module.splitString(input,delimiter)
    local result = {}
    local pos = 1
    while true do  
        local foundPos = string.find(input, delimiter, pos)  
        if not foundPos then  
            table.insert(result, string.sub(input, pos))  
            break  
        end  
        table.insert(result, string.sub(input, pos, foundPos - 1))  
        pos = foundPos + string.len(delimiter)  
    end  
      
    return result  
end
function module.tableLength(t)
    local count = 0  
    for _ in pairs(t) do  
        count = count + 1  
    end  
    return count  
end

-- 打印表 --不可用
function module.varDump(table)
    if type(table) ~= "table" then
        print(tostring(table))
        return
    end
    local indent = ""
    local function dump(tbl, depth)
        depth = depth or 0
        for key, value in pairs(tbl) do
            local valueType = type(value)
            local keyStr = tostring(key)
            if valueType == "table" then
                print(indent..keyStr..":")
                dump(value, depth + 1)
            else
                local valueStr = tostring(value)
                print(indent..keyStr..": "..valueStr)
            end
        end
    end
    dump(table)
end

function module.print_table(tbl, indent)
    indent = indent or ""
    for key, value in pairs(tbl) do
        local value_type = type(value)
        local key_str = tostring(key)
        if value_type == "table" then
            print(indent.. key_str.. ":")
            module.print_table(value, indent.. "    ")
        else
            print(indent.. key_str.. ": ".. tostring(value))
        end
    end
end

function module.startsWith(str, start)
    return str:sub(1, #start) == start
end
return module